<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateO2oCashRecordsTable1554107777 extends Migration
{
    /**
     * 现金收支表
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        if(!Schema::hasTable($prefix . 'o2o_cash_records')){
	        Schema::create($prefix . 'o2o_cash_records', function (Blueprint $table) {
		        $table->increments('id');
		        $table->string('item_type')->nullable();
		        $table->integer('item_id')->default(0);
		        $table->integer('clerk_id')->default(0);
		        $table->integer('amount')->default(0)->comment('金额');
		        $table->string('category')->default('daily')->comment('支出项目:daily_cost 日常支出；reject_cost 退货支出；other_cost 其他支出；order 销售收入；transfer 调货收入；other 其他收入');
		        $table->string('remark')->nullable();
		        $table->timestamps();
	        });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        Schema::drop($prefix . 'o2o_cash_records');
    }
}
